package com.cq.hd.app.controller;

import com.cq.hd.app.biz.WxOfficialBiz;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import java.io.IOException;

@RestController
@RequestMapping("/wxPub")
@Api(tags = "微信公众号相关接口")
public class WxPubController {

    @Autowired
    private WxOfficialBiz wxOfficialBiz;

    @ApiOperation(value = "微信服务器触发get请求用于检测签名")
    @GetMapping("/check")
    public void checkForGet(HttpServletRequest request, HttpServletResponse response) throws IOException {
        wxOfficialBiz.checkForGet(request, response);
    }

    @ApiOperation(value = "接收微信推送事件")
    @PostMapping("/check")
    public void checkForPost(HttpServletRequest request, HttpServletResponse response) throws IOException {
        wxOfficialBiz.checkForPost(request, response);
    }

}
